package com.gexin.model.user;

import com.gexin.common.utils.SQLUtils;
import com.gexin.model.user.base.BaseUserCollect;
import com.gexin.model.weixin.WeixinUser;
import com.jfinal.plugin.activerecord.Page;

/**
 * 业务名称:  t_user_collect(用户收藏商品表) 
 */
@SuppressWarnings("serial")
public class UserCollect extends BaseUserCollect<UserCollect> {
	public static final UserCollect dao = new UserCollect();

	public UserCollect findByProductIdAndUserId(Integer productId , Integer userId) {
		return	findFirst("select * from t_user_collect where product_id=? and user_id=?",productId,userId);
	}

	/**
	 * 获取用户的分页列表
	 * @param page
	 * @param size
	 * @param user
	 */
	public Page<UserCollect> findPageList(int page , int size , WeixinUser user) {
		SQLUtils sql = new SQLUtils(" from t_user_collect coll left join t_products pro on coll.product_id=pro.id where coll.user_id=?");
		System.out.println("select * "+sql.toString());
		return paginate(page,size,"select * ",sql.toString(),user.getId());
	}
}
